﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ElectronicsMarket.Service.IService;
using ElectronicsMarket.Service.Models;

namespace ElectronicsMarket.Service.ServiceImpl
{
    public class CategoryServiceImpl : ICategoryService
    {
        ElectronicsMarketDBClassesDataContext eMDataContext;
        public CategoryServiceImpl()
        {
            eMDataContext = new ElectronicsMarketDBClassesDataContext();
        }

        public IQueryable<CATEGORY> getAllCategory()
        {
            IQueryable<CATEGORY> categoryList = eMDataContext.CATEGORies;
            return categoryList;
        }

        public CATEGORY getCategoryById(int categoryId)
        {
            return eMDataContext.CATEGORies.Where(c => c.CATEGORY_ID == categoryId).FirstOrDefault();
        }
    }
}